package ua.vn.ticket_scanner.network.task.http;

import org.json.JSONException;

import ua.vn.ticket_scanner.network.data.JSONKeys;
import ua.vn.ticket_scanner.user.UserData;
import ua.vn.ticket_scanner.utils.Utils;


/**
 * Created by Ivan on 17.06.13.
 */
public class CheckTicketTask extends BaseTask {

    private String ticketCode;

    public CheckTicketTask(String ticketCode) {
        super(true);
        this.ticketCode = ticketCode;
    }

    @Override
    protected void makeJSON() {
        try {
            putJSON(JSONKeys.CMD, "validEticket");
            putJSON(JSONKeys.REQUEST_ID, "" + System.currentTimeMillis());
            putJSON(JSONKeys.CONTROLLER_ID, UserData.getInstance().getId());

            String secretKey = UserData.getInstance().getToken();
            if(secretKey == null)
                secretKey = Utils.md5(UserData.getInstance().getId());

            putJSON(JSONKeys.SECRET_KEY, secretKey);
            putJSON(JSONKeys.TICKET_CODE, ticketCode);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
